package com.geekaca.d09;

import java.io.*;


public class FileInputStream5 {
    public static void main(String[] args) {
        InputStream fis = null;
        try {
            fis = new FileInputStream("Hello.txt");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            File file = new File("Hello.txt");
            if (!file.exists()){
                System.out.println("文件不存在");
                return;
            }

            byte[] buffer = new byte[15];
//            int readed = fis.read(buffer);
//            System.out.println("此次搬运: "+ readed+" 内容: "+ new String(buffer));

            int length;
            while ((length = fis.read(buffer)) != -1) {
//                String s = new String(buffer);
                String s = new String(buffer,0,length);

                System.out.println(s);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
